<!DOCTYPE html>
<html>
	<head>
		<title>Filtering by several criteria (OR logic)</title>
		<link rel="stylesheet" href="../../../codebase/webix.css" type="text/css" charset="utf-8">
		<script src="../../../codebase/webix.js" type="text/javascript" charset="utf-8"></script>

		<link rel="stylesheet" type="text/css" href="../common/samples.css">
		<script src="../common/testdata.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<div class='header_comment'>Filtering by several criteria (OR logic) </div>
		<div class='sample_comment'>Type any text in the 'Film title' header and select some option in the 'Released' header. The grid will contain records that meet at least one criteria.</div>
		<div id="testA"></div>
		<script type="text/javascript" charset="utf-8">
		webix.ready(function(){
			grid = new webix.ui({
				container:"testA",
				view:"datatable",
				columns:[
					{ id:"rank",	header:"", css:"rank",  		width:50,	sort:"int"},
					{ id:"title",	header:["Film title", {content:"textFilter"}],width:200,	sort:"string"},
					{ id:"year",	header:["Released",  {content:"selectFilter"}] , width:80,	sort:"int"},
					{ id:"votes",	header:"Votes", 	width:100,	sort:"int"}
				],
				autoheight:true,
				autowidth:true,
				data:small_film_set
			});	

			//there is no built in or filters
			//but they can be created easily
			grid.filterByAll=function(){
				//get fitler values
				var title = this.getFilter("title").value;
				var year = this.getFilter("year").value;
				//unfilter if values was not selected
				if (!title	&& !year) return this.filter();
				//filter using or logic
				this.filter(function(obj){
					if (year !== "" && obj.year == year) return true;
					if (title !== "" && obj.title.toLowerCase().indexOf(title)!=-1) return true;
					return false;
				});
			};
		});
		</script>
	</body>
</html>